module.exports = function(app){
    // app.get('/',function(req,res){
    //     res.render('test',{issuccess:"success"})
    // });
    app.get('/weixin',function(req,res){
        var token="weixin";
        var signature = req.query.signature;
        var timestamp = req.query.timestamp;
        var echostr   = req.query.echostr;
        var nonce     = req.query.nonce;
        var oriArray = new Array();
        oriArray[0] = nonce;
        oriArray[1] = timestamp;
        oriArray[2] = token;
        oriArray.sort();
        var original = oriArray.join('');
        var jsSHA = require('jssha');
        var shaObj = new jsSHA('SHA-1', 'TEXT');
        shaObj.update(original);
        var scyptoString=shaObj.getHash('HEX');
        console.log('signature');
        console.log(signature);
        console.log('scyptoString');
        console.log(scyptoString);
        if(signature == scyptoString){
            res.send(echostr)
        } else {
            //验证失败
            console.log('验证失败');
        }
    });
    app.post('/weixin',function(req,res){});
}
